import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'giteePath',
    label: '所属git账户',
  },
  {
    component: 'Input',
    fieldName: 'title',
    label: '仓库标题',
  },
  {
    component: 'Input',
    fieldName: 'positoryUrl',
    label: '仓库地址',
  },
  {
    component: 'Input',
    fieldName: 'watching',
    label: '曝光',
  },
  {
    component: 'Input',
    fieldName: 'star',
    label: '点赞',
  },
  {
    component: 'Input',
    fieldName: 'fork',
    label: '拉取',
  },
  {
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    fieldName: 'publishTime',
    label: '创建时间',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.BWF_GITEE_STATUS 便于维护
      options: getDictOptions('bwf_gitee_status'),
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'releaseStatus',
    label: '仓库状态 ',
  },
];

export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '主键id',
    field: 'id',
  },
  {
    title: '所属git账户',
    field: 'giteePath',
  },
  {
    title: '仓库标题',
    field: 'title',
  },
  {
    title: '仓库地址',
    field: 'positoryUrl',
  },
  {
    title: '曝光',
    field: 'watching',
  },
  {
    title: '点赞',
    field: 'star',
  },
  {
    title: '拉取',
    field: 'fork',
  },
  {
    title: '创建时间',
    field: 'publishTime',
  },
  {
    title: '仓库状态 ',
    field: 'releaseStatus',
    slots: {
      default: ({ row }) => {
        // 可选从DictEnum中获取 DictEnum.BWF_GITEE_STATUS 便于维护
        return renderDict(row.releaseStatus, 'bwf_gitee_status');
      },
    },
  },
  {
    title: '备注',
    field: 'remark',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: '主键id',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '所属git账户',
    fieldName: 'giteePath',
    component: 'Input',
    rules: 'required',
  },
  // {
  //   label: '仓库标题',
  //   fieldName: 'title',
  //   component: 'Input',
  // },
  {
    label: '仓库地址',
    fieldName: 'positoryUrl',
    component: 'Input',
    rules: 'required',
  },
  // {
  //   label: '曝光',
  //   fieldName: 'watching',
  //   component: 'Input',
  // },
  // {
  //   label: '点赞',
  //   fieldName: 'star',
  //   component: 'Input',
  // },
  // {
  //   label: '拉取',
  //   fieldName: 'fork',
  //   component: 'Input',
  // },
  // {
  //   label: '仓库创建时间',
  //   fieldName: 'publishTime',
  //   component: 'DatePicker',
  //   componentProps: {
  //     showTime: true,
  //     format: 'YYYY-MM-DD HH:mm:ss',
  //     valueFormat: 'YYYY-MM-DD HH:mm:ss',
  //   },
  // },
  // {
  //   label: '仓库状态 ',
  //   fieldName: 'releaseStatus',
  //   component: 'RadioGroup',
  //   componentProps: {
  //     // 可选从DictEnum中获取 DictEnum.BWF_GITEE_STATUS 便于维护
  //     options: getDictOptions('bwf_gitee_status'),
  //     buttonStyle: 'solid',
  //     optionType: 'button',
  //   },
  // },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Input',
    rules: 'required',
  },
];
